import { Base } from "../entity/Base";
import { BaseDto } from "../dtos/BaseDto";
import moment from "moment";

export function transformResponseDto<D extends BaseDto, T extends Base>(
  entity: T,
  otherDto: Omit<D, keyof BaseDto>
): D {
  const dto = new BaseDto() as D;
  dto.id = entity.id;
  dto.createTime = moment(entity.createTime).format('YYYY-MM-DD HH:mm:ss');
  dto.updateTime = moment(entity.updateTime).format('YYYY-MM-DD HH:mm:ss');
  return { ...dto, ...otherDto }
}
